<?php

namespace app\index\model;

use think\Db;

/**
 * @author xjy
 */
class ExchangeModel
{
    static public function getList($param, $titles = null, $function = null)
    {
        $db = Db::table('exchange_rate')
            ->alias('a');
        !empty($param['name']) && $db->where('a.name', 'like','%'.$param['name'].'%');
        if (!empty($param['date'])) {
            $date = explode(' - ', $param['date']);
            count($date) == 2 &&
            $db->where('a.date', '>=', $date[0]) &&
            $db->where('a.date', '<=', $date[1]);
        }
        $db->order('a.date','desc');
        return \app\common\service\ToolService::downOrReturn($db, $param, $titles, $function);
    }

}
